/**
 * @(#)com.pattern.p_02_observer.observer.ConcreteObserver
 *
 * Copyright (c) 2014-2018 上海纬视瑞科技有限公司
 *
 * DESC:
 *
 */
package com.pattern.p_02_observer.observer;

import com.pattern.util.Log;

import java.io.Console;

/**
 * @author fusf
 * @version 1.0  2016/11/3
 */
public class ConcreteObserver extends Observer {

    private String subjectState;
    private String name;
    private ConcreteSubject subject;

    public ConcreteObserver(ConcreteSubject subject, String name) {
        this.subject = subject;
        this.name = name;
    }

    public Subject getSubject() {
        return subject;
    }

    public void setSubject(ConcreteSubject subject) {
        this.subject = subject;
    }

    /**
     * 实现抽象观察者中的更新操作
     */
    @Override
    public void update() {
        this.subjectState = subject.getSubjectState();
        Log.info("subjectState:"+subjectState+"-----------name:"+name);

    }
}
